<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('应用列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>应用名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>包名：</label>
                                <input type="text" name="packageName"/>
                            </li>
                            <li>
                                <label>签名：</label>
                                <input type="text" name="signName"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;查询</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="product:product:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="product:product:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="product:product:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="product:product:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('product:product:edit')}]];
        var removeFlag = [[${@permission.hasPermi('product:product:remove')}]];
        var yes_no = [[${@dict.getType('sys_business_yes_no')}]];
        var prefix = ctx + "product/product";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/form",
                updateUrl: prefix + "/form/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "应用",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '${comment}',
                    visible: false
                },
                {
                    field: 'name',
                    title: '应用名称'
                },
                {
                    field: 'icon',
                    title: '图标',
                    formatter: function(value, row, index) {
                        if (value !="" && value !=null) {
                            return "<img style='width: 50px;height: 50px;' src='" + value + "' />";
                        }
                        return "";
                    }
                },
                {
                    field: 'packageName',
                    title: '包名'
                },
                {
                    field: 'signName',
                    title: '签名'
                },
                {
                    field: 'packageKey',
                    title: '包秘钥'
                },
                {
                    field: 'loginLimit',
                    title: '登录设备限制'
                },
                {
                    field: 'oaidCert',
                    title: 'OAID证书管理'
                },
                {
                    field: 'introduction',
                    title: '一句话介绍'
                },
                {
                    field: 'isRecommend',
                    title: '是否推荐',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(yes_no, value);
                    }
                },
                {
                    field: 'channel',
                    title: '上线渠道',
                    formatter: function(value, row, index) {
                        if (value != null) {
                            return '<a href="javascript:void(0)" onclick="channelList(\'' + row.id + '\')">' + value + '</a>';
                        }
                    }
                },
                {
                    field: 'phoneBrand',
                    title: '上线品牌',
                    formatter: function(value, row, index) {
                        if (value != null) {
                            return '<a href="javascript:void(0)" onclick="phoneBrandList(\'' + row.id + '\')">' + value + '</a>';
                        }
                    }
                },
                {
                    field: 'version',
                    title: '最新版本'
                },
                {
                    field: 'publishTime',
                    title: '最新版本发布时间'
                },
                {
                    field: 'sort',
                    title: '推荐排序'
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    field: 'updateTime',
                    title: '更新时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function channelList(id) {
            $.modal.open("上线渠道列表",prefix + "/channelList/"+id);
        }

        function phoneBrandList(id) {
            $.modal.open("上线品牌列表",prefix + "/phoneBrandList/"+id);
        }
    </script>
</body>
</html>